﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <title>项目管理</title>
    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="/CSS/font-awesome-4.3.0/css/font-awesome.css?v=4.3.0" rel="stylesheet">
    <link href="/CSS/V3/jsTree/style.min.css" rel="stylesheet">
    <link href="/CSS/V3/animate.css" rel="stylesheet">
    <link href="/CSS/V3/style.css?v=2.2.0" rel="stylesheet">
    <script src="/Scripts/jquery-1.11.2.min.js"></script>
    <script src="/CSS/bootstrap3.3.5/js/bootstrap.js"></script>
    <script src="/JqueryPlug/V3/jsTree/jstree.min.js"></script>
    <script src="/JqueryPlug/laypage/laypage.js"></script>
    <script src="/Scripts/avalon.js"></script>
    <script src="/Scripts/jquery-migrate-1.1.0.min.js"></script>
    <script src="/Scripts/SZHLCommon.js?jsver=5"></script>
    <script>
        var model = avalon.define({
            $id: "XMGL",
            menutype: "-1",//菜单类型(0:我的客户.-1:"当前部门客户")
            queryuser: ComFunJS.getnowuser(),
            username: ComFunJS.getnowuser(),
            userlist: {},
            fnqueryuser: function (item) {
                if (item) {
                    model.queryuser = item;
                    model.CommonData.clear();
                    model.GetXMData();
                }
            },
            XMType: "0",
            XMContent: "",
            peo:"0",
            selXMType: "0",
            selXMContent: "",
            selpeo:"",
            CommonData: [],
            ViewDT: function (id) {
                //parent.ComFunJS.winviewform("/View/APPBaseView/APP_KHGL_LXJL.html?FormCode=KHGL&ID=" + id, "客户联系记录", "1000", "");
                parent.ComFunJS.winviewform("/ViewV3/APPBaseView/APP_XMGL_INFO.html?ID=" + id + "&pageType=view&r=" + Math.random(), "项目信息", "1000", "");
            },
            XMGLADD: function () {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=XMGL", "添加数据", "1000", "");
            },
            GetXMData: function () {
                $.getJSON('/API/FTAPI.ashx?Action=GETXMGLDATA', { P1: model.XMType, p: 1, P2: model.peo, Content: model.XMContent, b: model.menutype,  QUSER:  "'" + model.queryuser + "'" }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.CommonData.clear();
                        model.CommonData = resultData.Result;
                        model.selXMType = model.XMType;
                        model.selpeo = model.peo;
                        model.selXMContent = model.XMContent;
                        if (parseInt(resultData.Result1) > 0) {
                            $("#pageDiv").show();
                            laypage({
                                cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                                pages: Math.ceil(parseInt(resultData.Result1) * 1.0 / 8), //通过后台拿到的总页数
                                curr: 1, //初始化当前页
                                jump: function (e) { //触发分页后的回调
                                    if (model.selXMType != model.XMType || model.selXMContent != model.XMContent) {
                                        e.curr = 1;
                                    }
                                    $.getJSON('/API/FTAPI.ashx?Action=GETXMGLDATA', { P1: model.XMType, p: e.curr, P2: model.peo, Content: model.XMContent, b: model.menutype,  QUSER:  "'" + model.queryuser + "'" }, function (resultData) {
                                        model.CommonData.clear();
                                        model.CommonData = resultData.Result;
                                        model.selXMType = model.XMType;
                                        model.selXMContent = model.XMContent;
                                        model.selpeo = model.peo;
                                    })
                                }
                            });
                        }
                        else {
                            $("#pageDiv").hide();
                        }
                    }
                })
            },
            EditXMGL: function (Id) {

                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=XMGL&ID=" + Id+"&r="+Math.random(), "添加数据", "1000", "");
            },
            DelXMGL: function (scel) {
                parent.ComFunJS.winconfirm("确认要删除么", function () {

                    $.post("/API/FTAPI.ashx", { Action: "DELXMGL", P1: scel.ID }, function (result) {
                        var jsonresult = $.parseJSON(result)
                        if ($.trim(jsonresult.ErrorMsg) != "") {
                            ComFunJS.winwarning(jsonresult.ErrorMsg);
                        } else {
                            model.CommonData.remove(scel);
                            parent.ComFunJS.winsuccess('删除成功');
                        }
                    })
                }, function () { })
            },
            LB: function () {
                model.XMType = $(this).attr("val");
                if ($(this).hasClass("btn-primary")) {
                    model.GetXMData()
                }
                else {
                    $(".leibie").removeClass("btn-primary");
                    $(".leibie").addClass("btn-white");
                    $(this).removeClass("btn-white");
                    $(this).addClass("btn-primary");
                    model.GetXMData()
                }
            },
            getUserTree: function () {
                $.getJSON('/API/SZHLAPI.ashx?Action=GETUSERTREE', { P1: "1", }, function (resultData) {//获取可以查看日报的人员列表
                    if (resultData.Result) {
                        model.userlist = resultData.Result;

                        var tree = [];
                        if (resultData.Result.SubBranch.length > 0) {
                            $(resultData.Result.SubBranch).each(function (index, item) {
                                var subt = [];
                                $(item.SubUsers).each(function (index2, item2) {
                                    subt.push({ "id": item2.UserName, "text": item2.UserRealName, "icon": "none" });
                                })
                                tree.push({ "id": item.BranchID, "text": item.BranchName, "children": subt })
                            })
                        } else {

                            var chindren = [];
                            $(resultData.Result.SubUsers).each(function (index, item) {
                                var subu = { "id": item.UserName, "text": item.UserRealName, "icon": "none" };
                                chindren.push(subu);
                            })
                            tree.push({ "id": resultData.Result.BranchID, "text": resultData.Result.BranchName, "state": { "opened": true }, "children": chindren });
                        }
                        $("#using_json").jstree({
                            "core": { "data": tree }
                        }).bind("select_node.jstree", function (e, data) {
                            var node = data.instance.get_node(data.selected);
                            if (data.instance.is_leaf(node)) {
                                model.fnqueryuser(node.id);
                            } else {
                                model.fnqueryuser(node.children);
                            }

                        });
                    }

                })
            },
            SS: function () {
                model.peo = $(this).attr("val");
                if ($(this).hasClass("btn-primary")) {
                    model.GetXMData()
                }
                else {
                    $(".suoshu").removeClass("btn-primary");
                    $(".suoshu").addClass("btn-white");
                    $(this).removeClass("btn-white");
                    $(this).addClass("btn-primary");
                    model.GetXMData()
                }
            }
        });
        avalon.ready(function () {
            ComFunJS.initsetajax();
            model.GetXMData();
            model.getUserTree();
        })

    </script>

</head>
<body class="gray-bg" ms-controller="XMGL">
    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-3">
                <div class="ibox float-e-margins">
                    <div class="ibox-content" style="border: 0; border-right: 1px solid #e7eaec;">
                        <div class="file-manager">
                            <div class="hr-line-dashed"></div>
                            <button class="btn btn-primary btn-block" ms-click="XMGLADD()">添加项目</button>
                            <div class="hr-line-dashed"></div>
                            <h5>状态</h5> 
                            <button class="btn btn-white btn-sm leibie" type="button" val="" ms-click="LB()">全部</button>
                            <button class="btn btn-primary btn-sm leibie" type="button" val="0" ms-click="LB()">正在进行</button>
                            <button class="btn btn-white btn-sm leibie" type="button" val="1" ms-click="LB()">已结束</button>

                            <div class="hr-line-dashed"></div>  
                            <div class="clearfix"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-9">
                <div class="ibox">
                    <div class="box" style="margin-bottom:15px;">

                        <div class="pull-right mail-search">
                            <div class="input-group">
                                <input type="text" class="form-control input-sm" ms-duplex="XMContent" name="search" placeholder="输入项目名称查询">
                                <div class="input-group-btn">
                                    <button type="submit" class="btn btn-sm btn-primary" ms-click="GetXMData()">
                                        搜索
                                    </button>
                                </div>
                            </div>
                        </div>
                        <h2>
                            项目管理
                        </h2>
                        <div class="mail-tools tooltip-demo m-t-md">

                            <div class="btn-group pull-right">
                                <!--<button class="btn btn-white btn-sm">
                                    <i class="fa fa-arrow-left"></i>
                                </button>
                                <button class="btn btn-white btn-sm">
                                    <i class="fa fa-arrow-right"></i>
                                </button>-->
                                <div id="pageDiv" class="text-center"></div>
                            </div>
                            <div class="input-group-btn">
                                <button type="button" style="margin-left:0" class="btn btn-primary suoshu" val="0" ms-click="SS()">全部</button>
                                <button type="button" class="btn btn-white suoshu" val="1" ms-click="SS()">我创建的</button>
                                <button type="button" class="btn btn-white suoshu" val="2" ms-click="SS()">我负责的</button>
                                <button type="button" class="btn btn-white suoshu" val="3" ms-click="SS()">我参与的</button>
                            </div>
                        </div>

                    </div>

                </div>
                <div class="full-height-scroll">
                    <div class="table-responsive">
                        <table class="table  table-hover">
                            <thead>
                                <tr>

                                    <th>状态</th>
                                    <th>项目名称</th>
                                    <th>优先级</th>
                                    <th>进度</th>
                                    <th>负责人</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr ms-repeat-el="CommonData">
                                    <td>
                                        {{el.Status=="0"?"正在进行":"已结束"}}
                                    </td>
                                    <td>
                                        {{el.XMMC}}
                                    </td>
                                    <td>{{el.YXJ}}</td>
                                    <td>{{el.XMJD}}%</td>
                                    <td> {{ComFunJS.convertuser(el.XMFZR)}}</td>
                                    <td class="client-status">
                                        <a class=" btn btn-white btn-xs" ms-click="ViewDT(el.ID)"><i class="fa fa-search"></i> 查看 </a>
                                        <a class=" btn btn-primary btn-xs" ms-click="EditXMGL(el.ID)" ms-if="el.CRUser==username"><i class=" fa fa-pencil"></i> 编辑 </a>
                                        <a class="btn btn-danger btn-xs" ms-click="DelXMGL(el)" ms-if="el.CRUser==username"><i class="fa fa-trash-o"></i> 删除 </a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>

